package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbsfo.
 */
@Entity
@Table(name = "TTLSBSFO",schema = "TLSB")
@Configurable
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbsfoPK.class, versionField = "",  persistenceUnit="persistenceUnitTLBH",table = "TTLSBSFO", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbsfo {

	/** The tim fichero. */
	@Column(name = "TIM_FICHERO", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date timFichero;

	/** The cod bancopr. */
	@Column(name = "COD_BANCOPR")
    @NotNull
    private Short codBancopr;

	/** The cod prodserv. */
	@Column(name = "COD_PRODSERV")
    @NotNull
    private Short codProdserv;

	/** The cod subprodu. */
	@Column(name = "COD_SUBPRODU")
    @NotNull
    private Short codSubprodu;

	/** The cod comrefex. */
	@Column(name = "COD_COMREFEX",columnDefinition = "CHAR",length = 12)
    @NotNull
    private String codComrefex;

	/** The des asunacce. */
	@Column(name = "DES_ASUNACCE",columnDefinition = "CHAR", length = 40)
    @NotNull
    private String desAsunacce;

	/** The cod estadods. */
	@Column(name = "COD_ESTADODS",columnDefinition = "CHAR", length = 2)
    @NotNull
    private String codEstadods;

	/** The des path. */
	@Column(name = "DES_PATH",columnDefinition = "CHAR", length = 100)
    @NotNull
    private String desPath;

	/** The qnu pesofir. */
	@Column(name = "QNU_PESOFIR",columnDefinition = "DECIMAL", precision = 3, scale = 2)
    @NotNull
    private BigDecimal qnuPesofir;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The xti multirem. */
	@Column(name = "XTI_MULTIREM",columnDefinition = "CHAR",length=1)
    private Character xtiMultirem;

	/** The imp maxreg. */
	@Column(name = "IMP_MAXREG",columnDefinition = "DECIMAL", precision = 15, scale = 2)
    private BigDecimal impMaxreg;

	/** The cod sercrubd. */
	@Column(name = "COD_SERCRUBD")
    private Short codSercrubd;

	/**
	 * Gets the tim fichero.
	 *
	 * @return the tim fichero
	 */
	public Date getTimFichero() {
        return this.timFichero;
    }

	/**
	 * Sets the tim fichero.
	 *
	 * @param timFichero the new tim fichero
	 */
	public void setTimFichero(Date timFichero) {
        this.timFichero = timFichero;
    }

	/**
	 * Gets the cod bancopr.
	 *
	 * @return the cod bancopr
	 */
	public Short getCodBancopr() {
        return this.codBancopr;
    }

	/**
	 * Sets the cod bancopr.
	 *
	 * @param codBancopr the new cod bancopr
	 */
	public void setCodBancopr(Short codBancopr) {
        this.codBancopr = codBancopr;
    }

	/**
	 * Gets the cod prodserv.
	 *
	 * @return the cod prodserv
	 */
	public Short getCodProdserv() {
        return this.codProdserv;
    }

	/**
	 * Sets the cod prodserv.
	 *
	 * @param codProdserv the new cod prodserv
	 */
	public void setCodProdserv(Short codProdserv) {
        this.codProdserv = codProdserv;
    }

	/**
	 * Gets the cod subprodu.
	 *
	 * @return the cod subprodu
	 */
	public Short getCodSubprodu() {
        return this.codSubprodu;
    }

	/**
	 * Sets the cod subprodu.
	 *
	 * @param codSubprodu the new cod subprodu
	 */
	public void setCodSubprodu(Short codSubprodu) {
        this.codSubprodu = codSubprodu;
    }

	/**
	 * Gets the cod comrefex.
	 *
	 * @return the cod comrefex
	 */
	public String getCodComrefex() {
        return this.codComrefex;
    }

	/**
	 * Sets the cod comrefex.
	 *
	 * @param codComrefex the new cod comrefex
	 */
	public void setCodComrefex(String codComrefex) {
        this.codComrefex = codComrefex;
    }

	/**
	 * Gets the des asunacce.
	 *
	 * @return the des asunacce
	 */
	public String getDesAsunacce() {
        return this.desAsunacce;
    }

	/**
	 * Sets the des asunacce.
	 *
	 * @param desAsunacce the new des asunacce
	 */
	public void setDesAsunacce(String desAsunacce) {
        this.desAsunacce = desAsunacce;
    }

	/**
	 * Gets the cod estadods.
	 *
	 * @return the cod estadods
	 */
	public String getCodEstadods() {
        return this.codEstadods;
    }

	/**
	 * Sets the cod estadods.
	 *
	 * @param codEstadods the new cod estadods
	 */
	public void setCodEstadods(String codEstadods) {
        this.codEstadods = codEstadods;
    }

	/**
	 * Gets the des path.
	 *
	 * @return the des path
	 */
	public String getDesPath() {
        return this.desPath;
    }

	/**
	 * Sets the des path.
	 *
	 * @param desPath the new des path
	 */
	public void setDesPath(String desPath) {
        this.desPath = desPath;
    }

	/**
	 * Gets the qnu pesofir.
	 *
	 * @return the qnu pesofir
	 */
	public BigDecimal getQnuPesofir() {
        return this.qnuPesofir;
    }

	/**
	 * Sets the qnu pesofir.
	 *
	 * @param qnuPesofir the new qnu pesofir
	 */
	public void setQnuPesofir(BigDecimal qnuPesofir) {
        this.qnuPesofir = qnuPesofir;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the xti multirem.
	 *
	 * @return the xti multirem
	 */
	public Character getXtiMultirem() {
        return this.xtiMultirem;
    }

	/**
	 * Sets the xti multirem.
	 *
	 * @param xtiMultirem the new xti multirem
	 */
	public void setXtiMultirem(Character xtiMultirem) {
        this.xtiMultirem = xtiMultirem;
    }

	/**
	 * Gets the imp maxreg.
	 *
	 * @return the imp maxreg
	 */
	public BigDecimal getImpMaxreg() {
        return this.impMaxreg;
    }

	/**
	 * Sets the imp maxreg.
	 *
	 * @param impMaxreg the new imp maxreg
	 */
	public void setImpMaxreg(BigDecimal impMaxreg) {
        this.impMaxreg = impMaxreg;
    }

	/**
	 * Gets the cod sercrubd.
	 *
	 * @return the cod sercrubd
	 */
	public Short getCodSercrubd() {
        return this.codSercrubd;
    }

	/**
	 * Sets the cod sercrubd.
	 *
	 * @param codSercrubd the new cod sercrubd
	 */
	public void setCodSercrubd(Short codSercrubd) {
        this.codSercrubd = codSercrubd;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodBancopr: ").append(getCodBancopr()).append(", ");
        sb.append("CodComrefex: ").append(getCodComrefex()).append(", ");
        sb.append("CodEstadods: ").append(getCodEstadods()).append(", ");
        sb.append("CodProdserv: ").append(getCodProdserv()).append(", ");
        sb.append("CodSercrubd: ").append(getCodSercrubd()).append(", ");
        sb.append("CodSubprodu: ").append(getCodSubprodu()).append(", ");
        sb.append("DesAsunacce: ").append(getDesAsunacce()).append(", ");
        sb.append("DesPath: ").append(getDesPath()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("ImpMaxreg: ").append(getImpMaxreg()).append(", ");
        sb.append("QnuPesofir: ").append(getQnuPesofir()).append(", ");
        sb.append("TimFichero: ").append(getTimFichero()).append(", ");
        sb.append("XtiMultirem: ").append(getXtiMultirem());
        return sb.toString();
    }

	/** The entity manager. */
	@PersistenceContext(unitName="persistenceUnitTLBH")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsbsfoPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsbsfoPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsbsfoPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbsfo attached = Ttlsbsfo.findTtlsbsfo(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbsfo
	 */
	@Transactional(value="tlbh")
    public Ttlsbsfo merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbsfo merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbsfo().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbsfoes.
	 *
	 * @return the long
	 */
	@Transactional(value="tlbh")
	public static long countTtlsbsfoes() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbsfo o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbsfoes.
	 *
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbsfo> findAllTtlsbsfoes() {
        return entityManager().createQuery("SELECT o FROM Ttlsbsfo o", Ttlsbsfo.class).getResultList();
    }

	
	/**
	 * Find ttlsbsfo.
	 *
	 * @param id the id
	 * @return the ttlsbsfo
	 */
	@Transactional(value="tlbh")
	public static Ttlsbsfo findTtlsbsfo(TtlsbsfoPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbsfo.class, id);
    }

	
	/**
	 * Find ttlsbsfo entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbsfo> findTtlsbsfoEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbsfo o", Ttlsbsfo.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }
}
